// std functions
#include <iostream>
#include <stdexcept>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <math.h>

// boost functions
#include <boost/program_options.hpp>

// my functions
#include <print_error.h>
#include <program_options_helper.h>
#include <stlhelper.h>
#define DEBUG_LEVEL 6
#include <debug_func.h>
#include <blast_results.h>
#include "get_arg.h"
using std::string;
using std::cerr;
using std::cout;
using std::max;




// link with -lboost_filesystem-gcc -lboost_program_options-gcc
// program_options_helper.cpp
//-lboost_filesystem-gcc-d
//-L/usr/local/lib

using namespace program_options_helper;
namespace po = boost::program_options_lg;


//_______________________________________________________________________________________

//		process_command_line_options

//				from command line
//				Created [9/13/2001]

//_______________________________________________________________________________________
bool process_command_line_options(int argc, char* argv[], t_program_args& args)
{

	//
	// checked mandatory arguments
	//
	po::options_description mandatory_args("Mandatory Arguments");
	mandatory_args.add_options()
	("regex,r", 		po::value<string>(&args.regex)->set_name("REGEX")
								->default_value("(\\S+)"),
							"Regular expression for matching the sequence identifier. "
							"Defaults to first non-whitespace accession characters.");




	args.optional_args.add_options()
	("detail_errors,d", po::bool_switch(&args.detail_errors),
							"Report errors in detail\n");




	args.add_std_options();
	po::options_description all_args("");                              
	all_args.add(args.optional_args)
		.add(mandatory_args);

	// parse command line
	po::variables_map vm;
	po::store(po::command_line_parser(argc, argv).options(all_args).run(), vm);
	po::notify(vm);

	if (vm.count("version"))
	{
		print_version(cerr, *argv, "1.0\n"
			"\tHistory: \n\n"
			"\tv 1.0\1"
			"1-10-2006\1"
			"Initial version\n"
			);
		return false;
	}

	if (vm.count("help"))
	{
		string exe_description =
								"Calculate GC Content at the third position (GC3) and at "
								"synonmous sites (GC4d). Results are printed in "
								"tab-delimited columns:Identifier "
								"(extracted using the regular expression in --regex), GC3 and "
								"GC4d..\n";
		print_usage(cerr, string(*argv), "[OPTIONS] < SEQUENCES.FASTA > FILTERED.FASTA",
							all_args, exe_description, 80);
		return false;
	}
	//check_required_options(vm, mandatory_args);

	args.open_err_log();
	return true;
}

